﻿using System;

namespace ContainerVariations.Common
{
    public class SecureDoor : IDoor
    {
        private readonly IDoor _door;
        private readonly IDoorUser _user;

        public SecureDoor(IDoor door, IDoorUser user)
        {
            _door = door;
            _user = user;
        }

        public bool Open()
        {
            if (_user.MayOpenDoor)
            {
                Console.WriteLine("SecureDoor: Opening the door is permitted.");
                return _door.Open();
            }
            Console.WriteLine("SecureDoor: Opening the door is not permitted.");
            return false;
        }
    }
}